package api

import (
	"api-gateway/basic/config"
	__ "api-gateway/basic/proto"
	"api-gateway/handler/request"
	"github.com/gin-gonic/gin"
	"net/http"
)

func UpdateCleanerStatus(c *gin.Context) {
	var req request.UpdateCleanerStatus
	if err := c.ShouldBind(&req); err != nil {
		c.JSON(http.StatusBadRequest, gin.H{
			"code":    400,
			"message": "验证失败",
			"data":    err.Error(),
		})
		return
	}
	status, err := config.UserClient.UpdateCleanerStatus(c, &__.UpdateCleanerStatusReq{
		Id:            int64(req.Id),
		CleanerStatus: int64(req.CleaNerStatus),
	})
	if err != nil {
		c.JSON(http.StatusBadRequest, gin.H{
			"code":    400,
			"message": "修改保洁状态失败",
			"data":    err.Error(),
		})
		return
	}
	c.JSON(http.StatusOK, gin.H{
		"code":    200,
		"message": "修改保洁状态成功",
		"data":    status,
	})

}
